Skip to content

fix(gateway): preserve Responses tool linkage and structured output format#5624

Draft
ohnoah wants to merge 1 commit intoHelicone:mainfrom
ohnoah:fix/responses-callid-textformat
Draft

fix(gateway): preserve Responses tool linkage and structured output format#5624
ohnoah wants to merge 1 commit intoHelicone:mainfrom
ohnoah:fix/responses-callid-textformat

Conversation

@ohnoah
Copy link
Copy Markdown
Contributor

@ohnoah ohnoah commented Mar 3, 2026

Summary

This PR fixes two Responses API mapping issues in the gateway conversion layer:

  1. function_call linkage now prefers call_id over opaque id when constructing Chat Completions tool_calls[].id.
  2. Responses text.format is now mapped to Chat Completions response_format (including json_schema shape conversion).

Why

  • In multi-turn tool-call chains, function_call_output links by call_id. Preferring id could create mismatches and orphaned tool outputs.
  • Structured output requests that use Responses-native text.format (e.g. responses.parse) were not propagated into chat response_format, causing unconstrained plain-text output in provider-mapped flows.

Changes

  • Added resolveFunctionCallLinkId() and switched tool-call ID selection to use call_id first.
  • Added mapTextFormatToChatResponseFormat() to convert Responses text.format into Chat response_format, including json_schema mapping to { type: "json_schema", json_schema: { ... } }.
  • Added regression tests in openai-chat-to-responses-converters.test.ts:
    • prefers call_id over id for function calls
    • maps Responses text.format json_schema into chat response_format

Validation

  • corepack yarn jest --config packages/jest.config.ts packages/__tests__/llm-mapper/openai-chat-to-responses-converters.test.ts
  • corepack yarn jest --config packages/jest.config.ts packages/__tests__/llm-mapper

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 3, 2026

@ohnoah is attempting to deploy a commit to the Helicone Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant